export default {
    data() {
        return {
            scannerContent: ''
        }
    },
    created() {
        if (window.api != undefined) {
            var FNScanner = api.require('FNScanner')
            api.addEventListener({ // 通知当前本模块app进入后台。此时模块会进行一些资源的暂停存储操作，防止照相机回来之后黑屏
                name: 'pause'
            }, function(ret, err) {
                FNScanner.onPause()
            })

            api.addEventListener({ // 通知当前本模块app进入回到前台。此时模块会进行一些资源的恢复操作，防止照相机回来之后黑屏
                name: 'resume'
            }, function(ret, err) {
                FNScanner.onResume()
            })
        }
    },
    methods: {
        FNScannerFunc() {
            let self = this
            if (window.api != undefined) {
                self.scannerContent = ""
                var FNScanner = api.require('FNScanner')
                FNScanner.openScanner({
                    autorotation: true
                }, function(ret, err) {
                    if (ret) {
                        if (ret.eventType === 'success') { // 模块扫描成功事件
                            if (ret.content) {
                                self.scannerContent = ret.content
                            }
                        }
                    } else {
                        return false
                    }
                })
            }
        }
    }
};